/**
 * @Description:
 * @Author BPF
 * @create 2021/8/20 14:55
 */
export default {
  /**
   *  自动注册插件
   * @param app
   * @param options
   */
  install: (app, options) => {
    const pluginModules = import.meta.globEager('./*.js')
    Object.keys(pluginModules)
      .reduce((pre, cur) => {
        const key = cur
          .replace(/^\.\/(.*)\.\w+$/, '$1')
          .split('/')
          .pop()
        if (key != 'index') {
          pre.push(pluginModules[cur])
        }
        return pre
      }, [])
      .map(v => {
        app.use(v.default || {})
      })
  }
}
